#ifndef LEVEL_H_
#define LEVEL_H_
#include "elements/elements.h"
#include "map.h"

using namespace std;

class Level {
private:

	int globalIslandId;
	int globalRouteId;
	pair<int,int> globalHigh;

	string levelFilePath;
	string name;
	string description;
	string previewFilePath;
	int goalScore;

	Map map;

	vector<Island> islands;
	vector<Port> ports;
	vector<BattleShip> ships;
	vector<TradeRoute> routes;
	vector<BonusPack> packs;

	void drawRoutes();
	void drawPacks();
	void drawShips();
	void drawPorts();

	void highlightIsland(int x);
	void dehighlightIsland(int x);

public:
	Level();
	virtual ~Level();

	void resetLevel();

	float left,right,bottom,top;

	void setFilePath(string path){levelFilePath=path;};

	string getLevelFilePath(){return levelFilePath;};
	string getName(){return name;};
	string getDescription(){return description;};
	string getPreviewFilePath(){return previewFilePath;};
	int getGoalScore(){return goalScore;};

	Map& getMap(){return map;};
	vector<Island>& getIslands(){return islands;};
	vector<TradeRoute>& getRoutes(){return routes;};
	vector<BonusPack>& getPacks(){return packs;};
	vector<BattleShip>& getShips(){return ships;};
	vector<Port>& getPorts(){return ports;};

	int highlightFirst();
	void highlightNext();
	void endHighlight();
	int deleteHighlighted();

	void saveFile(int mode);
	void saveLevel(string levelFilePath);
	void loadLevel(string levelFilePath);
	void restoreLevel();

	void selectIsland(float x_,float y_){map.selectIsland(x_,y_,left,right,bottom,top);};
	void saveIsland();

	void printIslands();
	void printRoutes();

	void draw();

	int addBonusPack(int x, int y, int mode);
	void setBonusPack();

	void setLastShipsOrientation(int x,int y);
	int placeShip(int player, int x, int y);
	void deleteLastShip();


	void deletePorts();
	int placePort(int player,int x,int y);
	void setPortOrientation(int player, int x, int y);
	void setIslandOwner(int player);

	int addPointtoLastRoute(int x,int y);
	void deleteLastRoute();
	void updateLastRoutesLastMember(int x,int y);

	pair<float,float> fromWindowtoMap(pair<float,float> tmp);
	pair<float,float> fromHeighttoMap(pair<float,float> tmp);
	pair<int,int> fromMaptoHeight(pair<float,float> tmp);
	pair<int,int> fromWindowtoHeight(pair<float,float> tmp);

};

#endif /* LEVEL_H_ */
